home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / MosaicSRC / src / HTML_img.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  7.2 KB  |  168 lines

  1. /****************************************************************************
  2.  * NCSA Mosaic for the X Window System                                      *
  3.  * Software Development Group                                               *
  4.  * National Center for Supercomputing Applications                          *
  5.  * University of Illinois at Urbana-Champaign                               *
  6.  * 605 E. Springfield, Champaign IL 61820                                   *
  7.  * mosaic@ncsa.uiuc.edu                                                     *
  8.  *                                                                          *
  9.  * Copyright (C) 1993, Board of Trustees of the University of Illinois      *
  10.  *                                                                          *
  11.  * NCSA Mosaic software, both binary and source (hereafter, Software) is    *
  12.  * copyrighted by The Board of Trustees of the University of Illinois       *
  13.  * (UI), and ownership remains with the UI.                                 *
  14.  *                                                                          *
  15.  * The UI grants you (hereafter, Licensee) a license to use the Software    *
  16.  * for academic, research and internal business purposes only, without a    *
  17.  * fee.  Licensee may distribute the binary and source code (if released)   *
  18.  * to third parties provided that the copyright notice and this statement   *
  19.  * appears on all copies and that no charge is associated with such         *
  20.  * copies.                                                                  *
  21.  *                                                                          *
  22.  * Licensee may make derivative works.  However, if Licensee distributes    *
  23.  * any derivative work based on or derived from the Software, then          *
  24.  * Licensee will (1) notify NCSA regarding its distribution of the          *
  25.  * derivative work, and (2) clearly notify users that such derivative       *
  26.  * work is a modified version and not the original NCSA Mosaic              *
  27.  * distributed by the UI.                                                   *
  28.  *                                                                          *
  29.  * Any Licensee wishing to make commercial use of the Software should       *
  30.  * contact the UI, c/o NCSA, to negotiate an appropriate license for such   *
  31.  * commercial use.  Commercial use includes (1) integration of all or       *
  32.  * part of the source code into a product for sale or license by or on      *
  33.  * behalf of Licensee to third parties, or (2) distribution of the binary   *
  34.  * code or source code to third parties that need it to utilize a           *
  35.  * commercial product sold or licensed by or on behalf of Licensee.         *
  36.  *                                                                          *
  37.  * UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE FOR   *
  38.  * ANY PURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED          *
  39.  * WARRANTY.  THE UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE    *
  40.  * USERS OF THIS SOFTWARE.                                                  *
  41.  *                                                                          *
  42.  * By using or copying this Software, Licensee agrees to abide by the       *
  43.  * copyright law and all other applicable laws of the U.S. including, but   *
  44.  * not limited to, export control laws, and the terms of this license.      *
  45.  * UI shall have the right to terminate this license immediately by         *
  46.  * written notice upon Licensee's breach of, or non-compliance with, any    *
  47.  * of its terms.  Licensee may be held legally responsible for any          *
  48.  * copyright infringement that is caused or encouraged by Licensee's        *
  49.  * failure to abide by the terms of this license.                           *
  50.  *                                                                          *
  51.  * Comments and questions are welcome and can be sent to                    *
  52.  * mosaic-x@ncsa.uiuc.edu.                                                  *
  53.  ****************************************************************************/
  54.  
  55. #include "includes.h"
  56. #include "XtoI.h"
  57. #include "HTML.h"   /* THIS IS OK, PUBLIC INFO */
  58. #include "mosaic.h"
  59.  /* You don't need to see inside the gadget */
  60.  /* Maybe you do.... make sure that this only happens *inside the html gad */
  61. #include "HTMLImgMacro.h"
  62. #include "globals.h"
  63. #include "protos.h"
  64.  
  65. #define TRACE 0
  66.  
  67. #include "bitmaps/gopher_image.xbm"
  68. #include "bitmaps/gopher_movie.xbm"
  69. #include "bitmaps/gopher_menu.xbm"
  70. #include "bitmaps/gopher_text.xbm"
  71. #include "bitmaps/gopher_sound.xbm"
  72. #include "bitmaps/gopher_index.xbm"
  73. #include "bitmaps/gopher_telnet.xbm"
  74. #include "bitmaps/gopher_binary.xbm"
  75. #include "bitmaps/gopher_unknown.xbm"
  76.  
  77. static ImageInfo *gopher_image = NULL;
  78. static ImageInfo *gopher_movie = NULL;
  79. static ImageInfo *gopher_menu = NULL;
  80. static ImageInfo *gopher_text = NULL;
  81. static ImageInfo *gopher_sound = NULL;
  82. static ImageInfo *gopher_index = NULL;
  83. static ImageInfo *gopher_telnet = NULL;
  84. static ImageInfo *gopher_binary = NULL;
  85. static ImageInfo *gopher_unknown = NULL;
  86.  
  87. extern Pixmap CreateBitMapFromXBMData(UBYTE *, int, int, int);
  88. extern unsigned char *ReadXbmBitmap(FILE *, char *, int *, int *, int *);
  89.  
  90. /* Defined in gui.c */
  91. extern char *cached_url;
  92. extern mo_window *current_win;
  93. /* Defined in gui-documents.c */
  94. extern int interrupted;
  95. extern int loading_inlined_images;
  96. /* ------------------------------------------------------------------------ */
  97.  
  98. /* Image resolution function. */
  99.  
  100.  
  101. mo_status mo_free_image_data (void *ptr)
  102. {
  103.   ImageInfo *img = (ImageInfo *)ptr;
  104.  
  105.   if (!img)
  106.     return mo_fail;
  107.  
  108.   if (img->reds)
  109.     free (img->reds);
  110.   if (img->greens)
  111.     free (img->greens);
  112.   if (img->blues)
  113.     free (img->blues);
  114.   if (img->image_data)
  115.     free (img->image_data);
  116.  
  117.   return mo_succeed;
  118. }
  119.  
  120.  
  121. ImageInfo *ImageResolve (HTMLWidget hw, char *src, int noload)
  122. {
  123.   ImageInfo *img_data;
  124.  
  125.   if (!src) {
  126.     return NULL;
  127.   }
  128.  
  129.   /* Internal images. */
  130.   if (strncmp (src, "internal-", 9) == 0)
  131.     {    
  132.       if (strcmp (src, "internal-gopher-image") == 0)
  133.         RETURN_IMGINFO_FROM_BITMAP(gopher_image);
  134.       if (strcmp (src, "internal-gopher-movie") == 0)
  135.         RETURN_IMGINFO_FROM_BITMAP(gopher_movie);
  136.       if (strcmp (src, "internal-gopher-menu") == 0)
  137.         RETURN_IMGINFO_FROM_BITMAP(gopher_menu);
  138.       if (strcmp (src, "internal-gopher-text") == 0)
  139.         RETURN_IMGINFO_FROM_BITMAP(gopher_text);
  140.       if (strcmp (src, "internal-gopher-sound") == 0)
  141.         RETURN_IMGINFO_FROM_BITMAP(gopher_sound);
  142.       if (strcmp (src, "internal-gopher-index") == 0)
  143.         RETURN_IMGINFO_FROM_BITMAP(gopher_index);
  144.       if (strcmp (src, "internal-gopher-telnet") == 0)
  145.         RETURN_IMGINFO_FROM_BITMAP(gopher_telnet);
  146.       if (strcmp (src, "internal-gopher-binary") == 0)
  147.         RETURN_IMGINFO_FROM_BITMAP(gopher_binary);
  148.       if (strcmp (src, "internal-gopher-unknown") == 0)
  149.         RETURN_IMGINFO_FROM_BITMAP(gopher_unknown);
  150.     }
  151.  
  152.   src = mo_url_canonicalize (src, cached_url);
  153.  
  154.   /* Go see if we already have the image info hanging around. */
  155.   img_data = mo_fetch_cached_image_data (src);
  156.  
  157.   if (img_data)
  158.     {
  159.       free (src);
  160.       return (ImageInfo *)img_data;
  161.     }
  162.  
  163.   free (src);
  164.   return NULL;
  165. }
  166.  
  167. // mjw moved to HTMLamiga.c: int ImageLoadAndCache(HTMLGadClData *hw, char *src)
  168.